A widget for InstantSearch.js that lets users enter a search query.
searchBox
widget lets users perform a text-based query.
The search box is usually the main entry point to start the search on an InstantSearch page.
It’s usually placed at the top of a search experience, so users can start searching right away.
false
, new searches are only triggered by clicking the submit button or by pressing the Enter
key in the search box.query: string
: the current query stringsearch: function
: a function to trigger the search.search
method isn’t called, no search is made to Algolia and the UI doesn’t refresh.
If the search
method is called, the widget is rendered.This can be useful if you need to:html
function you can use as a tagged template.
Using html
lets you safely provide templates as an HTML string.
It works directly in the browser without a build step.
See more information, see Templating your UI.html
function is available from InstantSearch v4.46.0.root
: the root element of the widget.form
: the form element.input
: the input element.reset
: the reset button element.resetIcon
: the reset button icon.loadingIndicator
: the loading indicator element.loadingIcon
: the loading indicator icon.submit
: the submit button element.submitIcon
: the submit button icon.searchBox
widget, use the connectSearchBox
comnector.
Import it with a package manager or with a CDN.
Create a render function
init
lifecycle step) and each time results come back from Algolia (render
lifecycle step).true
if the search results take more than a certain time to come back from Algolia servers.
This can be configured on the instantsearch
constructor with the attribute stalledSearchDelay
.Create the custom widget
connector.widgetParams
, inside the renderFunction
.Instantiate